package m2.connector;

import java.util.ArrayList;

import m2.configuration.Configuration;
import m2.connector.iface.Role;

public class Connector {

	private ArrayList<Glue> listOfGlues;
	private ArrayList<Role> listOfRoles;
	private Configuration config;
	private String name;
	
	public Connector(String name) {
		this.name=name;
		listOfGlues = new ArrayList<Glue>();
		listOfRoles = new ArrayList<Role>();
		System.out.println("Ajout du connecteur " + this.name);
	}

	public void addRole(Role role) {
		listOfRoles.add(role);
		System.out.println("Ajout du role " + role.getName()  + " au connecteur " + this.name);
	}
	
	public void addGlue(Glue glue) {
		listOfGlues.add(glue);
		System.out.println("Ajout de la glue " + glue.getName() + " au connecteur " +this.name);
	}

	public Configuration getConfig() {
		return config;
	}

	public void setConfig(Configuration config) {
		this.config = config;
	}
	
	public ArrayList<Glue> getGlues() {
		return this.listOfGlues;
	}
	
	public ArrayList<Role> getRoles() {
		return this.listOfRoles;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public Role getRole(String name) {
		//System.out.println(getClass().getName());
		Role role = null;
		for (Role r : listOfRoles) {
			if(r.getName().equals(name)) {
				role = r;
			}
		}
		return role;
	}
	
} 
